package com.hanthink.web.controller.pc;

import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.core.page.TableDataInfo;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.framework.web.service.TokenService;
import com.hanthink.system.domain.repair.RepairTask;
import com.hanthink.system.service.repair.IRepairTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/system/repairtask")
public class RepairTaskController extends BaseController
{
    @Autowired
    private IRepairTaskService repairtaskService;

    @Autowired
    private TokenService tokenService;

    @PreAuthorize("@ss.hasPermi('system:repairtask:list')")
    @GetMapping("/list")
    public TableDataInfo list(RepairTask emQualityWeighing)
    {
        startPage();
        List<RepairTask> list = repairtaskService.selectRepairTaskList(emQualityWeighing);
        return getDataTable(list);
    }




    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(repairtaskService.selectRepairTaskById(id));
    }


    @Log(title = "维修任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RepairTask emQualityWeighing)
    {

        return toAjax(repairtaskService.insertRepairTask(emQualityWeighing));
    }


    @Log(title = "维修任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RepairTask emQualityWeighing)
    {
        return toAjax(repairtaskService.updateRepairTask(emQualityWeighing));
    }


    @Log(title = "维修任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(repairtaskService.deleteRepairTaskByIds(ids));
    }


}
